<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
function breakDataSource(item) {
  if(item.pointId || item.communicationName || item.personName) {
    item.id = item.personId;
    item.userId = item.account || item.communicationAccount;
    item.username = item.communicationName || item.personName;
    item.title = (item.communicationName || item.personName) + (item.userId ? '(' + item.userId + ')' : '');
    item.treeId = item.userId;
    item.disabled = true
  } else if(item.orgId || item.orgName) {
    item.title = item.orgName;
    item.id = item.orgId;
    item.treeId = item.orgId;
  } else if (item.deptId || item.deptName) {
    item.title = item.deptName;
    item.id = item.deptId;
    item.treeId = item.deptId;
  } else if (item.distributionGroupId || item.distributionGroupName) {
    item.title = item.distributionGroupName;
    item.id = item.distributionGroupId;
    item.treeId = item.distributionGroupId;
  } else if (item.equipmentTypeName || item.equipmentTypeCode) {
    item.title = item.equipmentTypeName;
    item.id = item.equipmentTypeCode;
    item.treeId = item.equipmentTypeCode;
  }

  if (item.orgList) item.children = item.orgList.map(breakDataSource)
  if (item.groupList) item.children = item.groupList.map(breakDataSource)
  if (item.personList) item.children = item.personList.map(breakDataSource)
  if (item.accountData) item.children = item.accountData.map(breakDataSource)
  if (item.equipmentType) item.children = item.equipmentType.map(breakDataSource)

  return item
}

function parse (data) {
  var result = JSON.parse(data);

  return result.result.map(breakDataSource);
}

















  fetch('http://192.168.1.142:8080/Communication/pubCommunicationAccount/getAllAccountByEquipment', { method: 'POST', headers: {'Content-Type': 'application/json'},  body: "{}" })
    .then(res => res.json())
    .then(res => {
      const { result, resultCode } = res;
      if (resultCode === '000000') {
        const dataSource = result.map(breakDataSource)
        /*organization.widgetObj._option = {
          ...organization.widgetObj._option,
          dataSource: dataSource
        };

        organization.widgetObj.render();*/
        console.log(dataSource);

        function filterEach(datas, title) {
          const childs = [];

          datas.forEach(item => {
            if (item.children) {
              item.children = filterEach(item.children, title);

              if (item.children.length) {
                childs.push(item)
              }
            } else {
              if (item.title.indexOf(title) > -1) {
                childs.push(item)
              }
            }
          })

          return childs;
        }

        // const data = filterEach(dataSource, '站值');

        // console.log(data);
      }
    });

// const text = $(search_input.__box).find('.input-filter').val();

  /*fetch('http://192.168.1.142:8080/Communication/pubCommunicationAccount/getGroupListByName', {})
    .then(res => res.json())
    .then(res => {
      const { result, resultCode } = res;
      if (resultCode === '000000') {
        const dataSource = result.map(breakDataSource)
        /!*organization.widgetObj._option = {
          ...organization.widgetObj._option,
          dataSource: dataSource
        };

        organization.widgetObj.render();*!/
        console.log(dataSource)
      }
    });

  fetch('http://192.168.1.142:8080/Communication/pubCommunicationAccount/listStructure', { method: 'POST', headers: {'Content-Type': 'application/json'},  body: "{}" })
    .then(res => res.json())
    .then(res => {
      const { result, resultCode } = res;
      if (resultCode === '000000') {
        const dataSource = result.map(breakDataSource)
        /!*organization.widgetObj._option = {
          ...organization.widgetObj._option,
          dataSource: dataSource
        };

        organization.widgetObj.render();*!/
        console.log(dataSource)
      }
    });*/

  let a, b;

  if (!(a === 1 || b === 2)) {

  }

  if ((a !== 1 && b !== 2)) {

  }
</script>
</body>
</html>